/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.io.FileInputStream;
import java.util.Arrays;

/**
 * <p>Project: jse2302 - Ex2
 * <p>Powered by webrx On 2023-06-27 14:14:39
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex2 {
    public static void main(String[] args) throws Exception {
        var fis = new FileInputStream("C:\\wnmp\\www\\index.php");
        byte[] buf = new byte[20];
        int len = fis.read(buf);
        System.out.println(Arrays.toString(buf));
        StringBuilder sbu = new StringBuilder();
        for(byte b : buf){
            sbu.append(String.format("%X",b));
        }
        System.out.println(sbu);
        String fileHead = sbu.toString();
        FileType[] fileTypes = FileType.values();
        for (FileType type : fileTypes) {
//            startsWith() 方法用于检测字符串是否以指定的前缀开始
            if (fileHead.startsWith(type.getValue())) {
                System.out.println(type);
            }
        }



    }
}
